package com.bestow.flowable.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.flowable.domain.WflApproveCandidateRule;
import com.bestow.flowable.service.IWflApproveCandidateRuleService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 候选人审批规则Controller
 * 
 * @author liliu
 * @date 2022-09-07
 */
@RestController
@RequestMapping("/flowable/approveCandidateRule")
public class WflApproveCandidateRuleController extends BaseController
{
    @Autowired
    private IWflApproveCandidateRuleService wflApproveCandidateRuleService;

    /**
     * 查询候选人审批规则列表
     */
    @PreAuthorize("@ss.hasPermi('flowable:approveCandidateRule:list')")
    @GetMapping("/list")
    public TableDataInfo list(WflApproveCandidateRule wflApproveCandidateRule)
    {
        startPage();
        List<WflApproveCandidateRule> list = wflApproveCandidateRuleService.selectWflApproveCandidateRuleList(wflApproveCandidateRule);
        return getDataTable(list);
    }

    /**
     * 导出候选人审批规则列表
     */
    @PreAuthorize("@ss.hasPermi('flowable:approveCandidateRule:export')")
    @Log(title = "候选人审批规则", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WflApproveCandidateRule wflApproveCandidateRule)
    {
        List<WflApproveCandidateRule> list = wflApproveCandidateRuleService.selectWflApproveCandidateRuleList(wflApproveCandidateRule);
        ExcelUtil<WflApproveCandidateRule> util = new ExcelUtil<WflApproveCandidateRule>(WflApproveCandidateRule.class);
        util.exportExcel(response, list, "候选人审批规则数据");
    }

    /**
     * 获取候选人审批规则详细信息
     */
    @PreAuthorize("@ss.hasPermi('flowable:approveCandidateRule:query')")
    @GetMapping(value = "/{candidateRuleId}")
    public AjaxResult getInfo(@PathVariable("candidateRuleId") Long candidateRuleId)
    {
        return AjaxResult.success(wflApproveCandidateRuleService.selectWflApproveCandidateRuleByCandidateRuleId(candidateRuleId));
    }

    /**
     * 新增候选人审批规则
     */
    @PreAuthorize("@ss.hasPermi('flowable:approveCandidateRule:add')")
    @Log(title = "候选人审批规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WflApproveCandidateRule wflApproveCandidateRule)
    {
        return toAjax(wflApproveCandidateRuleService.insertWflApproveCandidateRule(wflApproveCandidateRule));
    }

    /**
     * 修改候选人审批规则
     */
    @PreAuthorize("@ss.hasPermi('flowable:approveCandidateRule:edit')")
    @Log(title = "候选人审批规则", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WflApproveCandidateRule wflApproveCandidateRule)
    {
        return toAjax(wflApproveCandidateRuleService.updateWflApproveCandidateRule(wflApproveCandidateRule));
    }

    /**
     * 删除候选人审批规则
     */
    @PreAuthorize("@ss.hasPermi('flowable:approveCandidateRule:remove')")
    @Log(title = "候选人审批规则", businessType = BusinessType.DELETE)
	@DeleteMapping("/{candidateRuleIds}")
    public AjaxResult remove(@PathVariable Long[] candidateRuleIds)
    {
        return toAjax(wflApproveCandidateRuleService.deleteWflApproveCandidateRuleByCandidateRuleIds(candidateRuleIds));
    }
}
